﻿Imports System.Windows.Media
Imports System.Windows.Forms.Integration
Imports System.Windows


Public Class AffichageTexte
    Public Function Affiche(ByVal hauteur As Integer, ByVal largeurmax As Integer, ByVal texte As String) As Integer
        Const BaseHauteur As Double = 16.0
        Dim ratio As Double = hauteur / BaseHauteur
        LeTexte.Text = texte
        Dim titi As New ScaleTransform(1, 1, 0, BaseHauteur / 2.0)
        GridControl.RenderTransform = titi
        Me.UpdateLayout()
        Dim textwidth As Double = LeTexte.ActualWidth
        Dim textwidthapresratio As Double = textwidth * ratio
        If textwidthapresratio > largeurmax Then
            Me.Width = largeurmax
            GridControl.ColumnDefinitions(0).Width = New GridLength((largeurmax / ratio) - TroisPetitsPoints.ActualWidth, GridUnitType.Pixel)
        Else
            Me.Width = textwidthapresratio
            GridControl.ColumnDefinitions(0).Width = New GridLength(1, GridUnitType.Auto)

        End If
        Dim TailleApresRatio As New ScaleTransform(ratio, ratio, 0, BaseHauteur / 2.0)
        'GridControl.RenderTransform = TailleApresRatio
        GridControl.LayoutTransform = TailleApresRatio
        Me.UpdateLayout()
        Return Math.Min(largeurmax, CInt(textwidthapresratio))
    End Function
End Class
